package com.lantosec.hmrp.modules.eval.controller.app;


import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.kit.tree.TreeNodeVo;
import com.lantosec.hmrp.core.log.ControllerLog;
import com.lantosec.hmrp.core.log.LogType;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.eval.entity.EvalPlan;
import com.lantosec.hmrp.modules.eval.entity.EvalPlanList;
import com.lantosec.hmrp.modules.eval.service.IEvalPlanService;
import com.lantosec.hmrp.modules.eval.service.IEvalSchemeService;
import com.lantosec.hmrp.modules.eval.vo.EvalPlanVO;
import com.lantosec.hmrp.modules.eval.vo.EvalSchemeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 *
 * 考评计划 控制器
 *
 * @author AutoCode
 * @since 2020-03-17
 */
@Api(value = "考评计划控制器APP端", tags = "考评计划控制器APP端")
@RestController
@RequestMapping("/eval/app/plan")
@Log4j2
public class EvalPlanAppController extends BaseController {
    @Autowired
    private IEvalPlanService service;

    @Autowired
    private IEvalSchemeService iEvalSchemeService;

    @PostMapping("create")
    @ControllerLog(name = "新增考评计划数据", type = LogType.add)
    @ApiOperation(value = "新增考评计划数据")
    public Result<Integer> create(@ApiParam(value = "考评计划封装对象", required = true) @RequestBody @Validated EvalPlanList evalPlanList){
        service.saveAll(evalPlanList);
        return Result.ok();
    }

    @GetMapping("getEvalSchemeAll")
    @ApiOperation(value = "查询所有的考评方案")
    public Result<List<EvalSchemeVO>> getEvalSchemeAll(){
        List<EvalSchemeVO> evalSchemeVOList = iEvalSchemeService.getEvalScheme();
        return Result.ok(evalSchemeVOList);
    }

    @GetMapping("getDeptUserTree")
    @ApiOperation(value = "查询部门人员树")
    public Result<List<TreeNodeVo>> getDeptUserTree(){
        List<TreeNodeVo> deptUserTree = iEvalSchemeService.getDeptUserTree();
        return Result.ok(deptUserTree);
    }

    @GetMapping("getDeptPositionTree")
    @ApiOperation(value = "查询部门岗位树")
    public Result<List<TreeNodeVo>> getDeptPositionTree(){
        List<TreeNodeVo> deptPositionTree = iEvalSchemeService.getDeptPositionTree();
        return Result.ok(deptPositionTree);
    }
}
